package com.smartrm.globalinfrcore.event;

import org.apache.tomcat.util.json.JSONParser;
import org.springframework.context.ApplicationEvent;

import java.time.LocalDateTime;
import java.util.UUID;

/*
 * @program: common-starters
 * @description: 领域事件
 * @author: houhong
 * @create: 2023-01-10 15:12
 */
public abstract class DomainEvent extends ApplicationEvent {


    private String eventId;
    private LocalDateTime occurTime;

    public DomainEvent(Object source) {
        super(source);
        eventId = UUID.randomUUID().toString();
        occurTime = LocalDateTime.now();

    }

    public String getEventName() {
        return (String) this.source;
    }

    /*
     * 业务key
     */
    public abstract String key();

    public String getEventId() {
        return eventId;
    }

    public void setEventId(String eventId) {
        this.eventId = eventId;
    }

    public LocalDateTime getOccurTime() {
        return occurTime;
    }

    public void setOccurTime(LocalDateTime occurTime) {
        this.occurTime = occurTime;
    }

}